Skip to content

fix: preserve static MCP meta in converted function tools#2769

Merged
seratch merged 1 commit into
mainfrom
fix/mcp-static-meta-function-tool
Mar 25, 2026
Merged

fix: preserve static MCP meta in converted function tools#2769
seratch merged 1 commit into
mainfrom
fix/mcp-static-meta-function-tool

Conversation

@seratch
Copy link
Copy Markdown
Member

@seratch seratch commented Mar 24, 2026

This pull request fixes converted MCP function tools dropping static _meta at execution time.

MCPUtil.to_function_tool() previously converted MCP tools into FunctionTool instances without carrying static request metadata through to invoke_mcp_tool(). That meant MCP servers relying on _meta for request-scoped hints such as auth, locale, or session data could silently lose that information when tools were invoked through the SDK's function-tool path.

This change keeps the fix narrow to the MCP conversion layer. It extracts static MCP metadata from the MCP tool object, including the current mcp.types.Tool Pydantic shape, and binds that metadata into invoke_mcp_tool() so the existing merge logic with tool_meta_resolver remains the single execution path.

The pull request also adds regression coverage to verify that:

  • static MCP metadata survives to_function_tool() conversion and reaches server.call_tool(...)
  • static MCP metadata still merges correctly with resolver-produced metadata and preserves existing precedence rules

@seratch seratch added this to the 0.13.x milestone Mar 24, 2026
@github-actions github-actions Bot added bug Something isn't working feature:mcp labels Mar 24, 2026
@seratch seratch merged commit 8e1915e into main Mar 25, 2026
9 checks passed
@seratch seratch deleted the fix/mcp-static-meta-function-tool branch March 25, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feature:mcp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant